package demo2;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2021/10/29
 * Time: 9:58
 * Description:
 */
/*class Student implements Comparable<Student>{
    public int age;
    public double score;
    public String name;

    public Student(int age, double score, String name) {
        this.age = age;
        this.score = score;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", score=" + score +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        *//*if(this.age > o.age) {
            return 1;
        }else if(this.age == o.age) {
            return 0;
        }else {
            return -1;
        }*//*
        // return this.age-o.age;
        //return o.age-this.age;
        return this.name.compareTo(o.name);
    }
}*/
interface A {
    public static void func() {
        System.out.println("fasfdsa");
    }
    void func2();
}
class Student {
    public int age;
    public double score;
    public String name;

    public Student(int age, double score, String name) {
        this.age = age;
        this.score = score;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", score=" + score +
                ", name='" + name + '\'' +
                '}';
    }
}

class AgeComparator implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {
        return o1.age-o2.age;
    }
}
class NameComparator implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {
        return o1.name.compareTo(o2.name);
    }
}

class ScoreComparator implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {
        return (int)(o1.score-o2.score);
    }
}
interface TT1 {
    void funcTT1();
}
//扩展
interface TT2 extends TT1{
    void funcTT2();
}
//扩展
interface TT3 extends TT2{
    void funcTT3();
}

class TTClass implements TT3 {
    public void funcTT3() {
        System.out.println("3");
    }

    @Override
    public void funcTT1() {

    }

    @Override
    public void funcTT2() {

    }
}

public class Test4 {

    public static void main(String[] args) {
        Student[] students = new Student[3];
        students[0] = new Student(23,58.9,"zhangsan");
        students[1] = new Student(13,28.9,"wangwu");
        students[2] = new Student(33,48.9,"lisi");

        AgeComparator ageComparator = new AgeComparator();
        NameComparator nameComparator = new NameComparator();
        ScoreComparator scoreComparator = new ScoreComparator();
        Arrays.sort(students,scoreComparator);
        System.out.println(Arrays.toString(students));
    }


    public static void main5(String[] args) {
        A.func();
    }

    public static void main3(String[] args) {
        Student student1 = new Student(3,58.9,"zhangsan");

        Student student2 = new Student(13,28.9,"wangwu");

    }

    public static void main4(String[] args) {
        Student[] students = new Student[3];
        students[0] = new Student(23,58.9,"zhangsan");
        students[1] = new Student(13,28.9,"wangwu");
        students[2] = new Student(33,48.9,"lisi");

        Arrays.sort(students);

        System.out.println(Arrays.toString(students));

    }

    public static void main1(String[] args) {
        int[] array = {1,12,31,4,5};
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
    }
}
